<!-- search area   -->
<div class="row searchLineWrap">
	<form class="form-horizontal" method="post"
		action="${cxt!}/message/smsPlugin/pluginRecive/list" id="searchForm">
		<div class="col-md-12">
			<div class="row">
				<div class="col-md-4">
					<div class="form-group">
						<label class="col-md-5 control-label">${_res["smsApiConfig.smsName"]}</label>
						<div class="col-md-7">
							<input type="text" class="form-control" name="smsPluginConfig.l_name" placeholder="${_res['smsApiConfig.smsName']}" value="${paramMap['sms_plugin.l_name']}" />
						</div>
					</div>
				</div>

				<div class="col-md-4">
					<div class="form-group">
						<label class="col-md-5 control-label">${_res["smsApiConfig.status"]}</label>
						<div class="col-md-7">
							<#dict type="select" name="smsPluginConfig.f_status" dictCode="COMMON_STATUS" value="${paramMap['sms_plugin.f_status']}" />
						</div>
					</div>
				</div>				
			
				<div class="col-md-3">
					<div class="form-group">
						<% if(hasPrivilegeUrl("smsPluginList")){ %>
						   <button type="button" class="btn btn-primary pull-right" onclick="ajaxForm('content','searchForm')"> <i class="fa fa-search m-l-sm m-r-xs"></i>${_res["system.search"]}</button>
						<% } %>
					</div>
				</div>
			</div>
		</div>
	</form>
</div>
<!-- search area end  -->

<div class="row searchLineWrap">
	<p>
		<% if(hasPrivilegeUrl("smsPluginAdd")){ %>
			<a href="javascript:void(0);" onClick="ajaxContent('/message/smsPlugin/pluginRecive/add/a');" class="btn btn-primary pull-left">${_res["smsApiConfig.addAPI"]}</a>
		<% } %>
		<div class="clearfix"></div>
	</p>
	<table class="table table-bordered">
		<thead>
			<tr>
				<th>${_res["smsApiConfig.smsName"]}</th>
				<th>${_res["smsApiConfig.default"]}</th>
				<th>${_res["smsApiConfig.numberOfTimesToSend"]}</th>
				<th>${_res["smsApiConfig.status"]}</th>
				<th>${_res["system.createtime"]}</th>
				<th>${_res["system.operator"]}</th>
			</tr>
		</thead>
		<tbody>
			<% for(item in splitPage.list!){ %>
			<tr >
				<td>${item.name!}</td>
				<td><#dict type="lable" value='${item.defaultvalue!}' dictCode="COMMON_YN"/></td>
				<td>${item.sendnum!}</td>
				<td><#dict type="lable" value='${item.status!}' dictCode="COMMON_STATUS"/></td>
				<td>${item.createtime!,dateFormat="yyyy-MM-dd HH:mm"}</td>
				<td><% if(hasPrivilegeUrl("smsPluginView")){ %>
					<button type="button" class="btn btn-sm btn-link" onClick="ajaxContent('/message/smsPlugin/pluginRecive/view/${item.id!}');">${_res["system.view"]}</button>
					<% } %> 
					<% if(hasPrivilegeUrl("smsPluginEdit")){ %>
					<button type="button" class="btn btn-sm btn-link" onClick="ajaxContent('/message/smsPlugin/pluginRecive/update/e-${item.id!}')">${_res["system.edit"]}</button>
					<% } %> 
					<% if(hasPrivilegeUrl("smsPluginDelete")){ %>
					<button type="button" class="btn btn-sm btn-link" onClick="ajaxDelete('/message/smsPlugin/pluginRecive/delete/${item.id!}')">${_res["system.delete"]}</button>
					<% } %>
					
					<% if(hasPrivilegeUrl("/message/sms/regvcode")){ %>
					<button type="button" class="btn btn-sm btn-link" data-toggle="modal" data-target="#myModal" data-whatever="${item.id!}">${_res["system.send"]}</button>
					<% } %>
				</td>
			</tr>
			<% } %>
		</tbody>
	</table>
	<div id="splitPageDiv"><#page formId="searchForm" /></div>
	<#nav />
</div>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModaLabel">
  	<form class="form-horizontal" id="smsSendForm">
		  <div class="modal-dialog" >
		    <div class="modal-content">
		     <div class="modal-header">
		        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
		        <h4 class="modal-title" id="myModaLabel">${_res["smsMessage"]}</h4>
		      </div>
		      <input type="hidden"  id="pluginID" name="pluginID" >
		      <div class="modal-body">
					<div class="partentDivWrap">
					  <div class="htmleaf-content bgcolor-3">
							<div id="main-container">
								<div class="form-group">
									<label for="namebasic" class="col-md-3 control-label">${_res["sms.countrycode"]}
										<span class="fontColorRed">&nbsp;*</span>
									</label>
									<div class="col-md-6">
										<input type="text" class="form-control" id="countrycode" placeholder="${_res['sms.countrycode']}">
									</div>
								</div>
								
							    <div class="form-group">
									<label for="namebasic" class="col-md-3 control-label">${_res["customer.telephone"]}
										<span class="fontColorRed">&nbsp;*</span>
									</label>
									<div class="col-md-6">
										<input type="text" class="form-control" id="tel" placeholder="${_res['customer.telephone']}" >
									</div>
								</div>
								
								 <div class="form-group">
								 	<label for="namebasic" class="col-md-3 control-label">${_res["sms.send.result"]}
									</label>
									
									<div class="col-md-6">
										<textarea class="form-control" rows="3" id="smsResult" placeholder="${_res['sms.send.result']}"></textarea>
									</div>
								</div>
						    </div>
						</div>              
					</div>
		      </div>
		      <div class="modal-footer">
		        <button type="button" class="btn btn-warning" data-dismiss="modal">${_res["system.return"]}</button>
		        <button type="button" class="btn btn-primary" onClick="smssend();">${_res["system.send"]}</button>
		      </div>
		    </div>
		  </div>
	 </form>
</div>

<script>
$(document).ready(function(){
	$('#myModal').on('show.bs.modal', function(event) {
		var button = $(event.relatedTarget); // Button that triggered the modal
		var pluginID = button.data('whatever'); // Extract info from data-* attributes
		$("#pluginID").val(pluginID);
	});
});

function smssend(){
	var countryCode = $("#countrycode").val();
	var tel = $("#tel").val();
	var pluginID = $("#pluginID").val();
	var data = "pluginID=" + pluginID + "&tel=" + tel;
	data += "&da=" + countryCode + tel;
	var url = "${cxt!}/message/sms/regvcode";
	$.ajax({
		url : url,
		type : "post",
		dataType : "json",
		data : data,
		success : function(data) {
		   $("#smsResult").val(data.code + ": " + data.result);
		}
	});
};
</script>